﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebClient.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        function onSelectedIndexChanged_DistrictHeader() {
            var city = document.getElementsByName("ListCityHeader").item(0);
            var district = document.getElementsByName("ListDistrictHeader").item(0);
            // if foodtype is have selected value
            var foodtype = document.getElementsByName("ListFoodTypeHeader").item(0);
            if (foodtype.value != "0" && district.value != "0") {
                window.location.href = "../Home/SearchRestaurants?idcity=" + city.value + "&iddistrict=" + district.value + "&idfoodtype=" + foodtype.value;
            }
        }
        function onSelectedIndexChanged_FoodTypeHeader() {
            var city = document.getElementsByName("ListCityHeader").item(0);
            var foodtype = document.getElementsByName("ListFoodTypeHeader").item(0);
            // if district is have selected value
            var district = document.getElementsByName("ListDistrictHeader").item(0);
            if (district.value != "0" && foodtype.value != "0") {
                window.location.href = "../Home/SearchRestaurants?idcity=" + city.value + "&iddistrict=" + district.value + "&idfoodtype=" + foodtype.value;
            }
        }
    </script>
    <script type="text/javascript">
        $(function () {
            // Document.ready -> link up remove event handler 
            $(".RemoveLink").click(function () {
                // Get the id from the link 
                var recordToDelete = $(this).attr("data-id");

                if (recordToDelete != '') {

                    // Perform the ajax post 
                    $.post("/Home/RemoveFromCart", { "id": recordToDelete },
                    function (data) {
                        // Successful requests get here 
                        // Update the page elements 
                        $('#row-' + data.DeleteId).fadeOut('slow');
                        $('#cart-total').text(data.CartTotal);
                    });
                }
            });

        });

        function handleUpdate() {
            // Load and deserialize the returned JSON data 
            var json = context.get_data();
            var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);

            // Update the page elements 
            $('#row-' + data.DeleteId).fadeOut('slow');
            $('#cart-total').text(data.CartTotal);
        } 
    </script> 
    <div id="PartialDiv">
		<% Html.RenderPartial("Templates/TH_Search", Model); %>
	</div>
    <div id="content">
        <% var restaurant = Model.RestaurantModel.GetModel.LstObjModel[0]; %>
        <% var lstMenu = restaurant.Menus.ToList(); %>
        <div id="container">
            <a name="toppage"></a>
            <div style="margin-top:10px;">&nbsp;</div>
            <div id="div_rest" style="width:800px;"></div>
            <div class="divleft">
                <div id="closed">This restaurant is currently closed</div>
                <center>Check below for business times.</center>
                <table border="0" width="520" cellspacing="0" cellpadding="0" style="line-height:20px; margin-bottom: 10px;">
                    <tr>
                        <td colspan="3" class="restta"><%= restaurant.Name%></td>
                    </tr>
                    <tr>
                        <td width="180">Estimated Service Time</td>
                        <td width="180"><b><%= restaurant.EstimatedServiceTime%> minutes</b></td>
                    </tr>
                    <tr>
                        <td>Payment Types</td>
                        <td>
                            <img src="../../Content/Images/Home/iconcash.jpg" title="Cash Payment" width="21" height="16" border="0" style="margin-right: 5px;" />
	                    </td>
                    </tr>
<%--                    <tr>
                        <td style="padding-top: 10px;" valign="top">Minimum Order</td>
                        <td style="padding-top: 10px;" valign="top">200,000 VND</td>
                    </tr>
                    <tr>
                        <td valign="top">Delivery Fee</td>
                        <td valign="top">30,000 VND</td>
                    </tr>--%>
                </table>
                <div style="float: left; width: 360px;">
                    <b>Business Times</b><br>
                    <table>
                        <tr>
                            <td valign="top">Today:&nbsp;</td>
                            <td>
                                <%= restaurant.TimeStart%>-<%= restaurant.TimeEnd%> - All days of the week
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="float: left; width: 140px;">
                    <br>
                    <div id="fb-root"></div>
                    <div class="fb-like" data-send="true" data-layout="button_count" data-width="140" data-show-faces="false"></div>
                </div>
                <div style="clear: both;"></div>
                <div id="menuler" style="line-height:16px; text-align:center; width: 520px;">
                    <br /><b>Menu</b><br />
                    <% foreach(var menu in lstMenu)
                       { %>
                        - <a href="#menu-<%= menu.ID %>"><%= menu.Name %></a>
                    <% } %>
                </div>
                <% foreach(var menu in lstMenu)
                   { %>
                    <div id="menu-<%= menu.ID %>" style="line-height:18px;border: 1px solid #F3F3F3; margin-top:20px; width:520px;">
                        <div style="float: left; width: 500px; background: #f8f8f8;color:#FF0000; border-bottom: 1px solid #DBDBDB; margin-bottom: 5px; height: 20px;">
                            <p style="font-size: 18px; font-weight:bold;line-height:18px; padding-left:5px;">
                            <a name="menu532"></a>
                            <%= menu.Name %></p>
                        </div>
                        <div style="float: left; width: 20px; background: #f8f8f8;color:#FF0000; border-bottom: 1px solid #DBDBDB; margin-bottom: 5px; height: 20px;">
                            <a href="#toppage">
                                <img src="../../Content/Images/Home/toppage.gif" width="15" height="15">
                            </a>
                        </div>
                        <div style="clear: both;"></div>
                        <div>
                            <table border="0" width="100%" cellspacing="0" cellpadding="0" style="line-height:25px; font-size: 11px;">
                                <% var lstFood = menu.Foods.ToList(); %>
                                <% for (int i = 0; i < lstFood.Count; i++ )
                                   { %>
                                    <tr>
                                        <td valign="top" style=" padding-left: 5px; line-height: 20px; color: #333333;">
	                                        <b><%= Html.ActionLink((i + 1).ToString() + " " + lstFood[i].Name, "ShowFoodDetail", "Home", new { id = lstFood[i].ID }, new { @id = lstFood[i].ID, @Style="color: black; font-weight: normal", @class = "popup" + lstFood[i].ID })%></b><br />
                                            <script type="text/javascript">
                                                $('.popup<%= lstFood[i].ID %>').popupWindow({
                                                    centerBrowser: 1,
                                                    height: 500,
                                                    width: 800,
                                                    top: 50,
                                                    left: 50,
                                                    scrollbars: 1,
                                                    resizable: 1
                                                }); 
                                            </script>
                                        </td>
                                        <td style="width:80px;text-align:right;padding-right:5px;line-height:15px; " valign="middle">
                                            <%= lstFood[i].Price %>	USD
                                        </td>
                                        <td style="width:130px;vertical-align:top; text-align: right; " id="tdurun_4163">
                                            <%
                                                var arrTimeStart = restaurant.TimeStart.Split(new char[] { ':' });
                                                var timeStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, int.Parse(arrTimeStart[0].Trim()), int.Parse(arrTimeStart[1].Trim()), 0);
                                                var arrTimeEnd = restaurant.TimeEnd.Split(new char[] { ':' });
                                                var timeEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, int.Parse(arrTimeEnd[0].Trim()), int.Parse(arrTimeEnd[1].Trim()), 0);
                                                if (timeStart <= DateTime.Now && DateTime.Now <= timeEnd)
                                                {
                                                %>
                                                    <%= Html.ActionLink("Add to cart", "AddToCart", "Home", new { idrestaurant = restaurant.ID, id = lstFood[i].ID }, new { @class = "btnAddToCart", })%>
                                                <%
                                                }
                                                else
                                                {
                                                %>
                                                    <input type="submit" name="crtb" id="imgprd_4163" title="Closed" value="Closed" style="background-image: url(../../Content/Images/Home/bgbutton.jpg); color: #FFFFFF; font-size: 12px; font-weight: bold; border: 1px #DBDBDB solid; height: 20px;" rel="#restclosed" />
                                                    <div class="closed_overlay" id="restclosed">
                                                        <div style="float: left; width: 25px; color:#F00; text-align: right; font-size: 16px; cursor:pointer; padding-right: 5px; position: absolute; right: 0px; top: 0px;" class="close">x</div>
                                                        <center><b>This restaurant is currently closed</b><br>
                                                        Please come back another time to make your order<br><br>
                                                        <a class="close" style="cursor: pointer;">[Close this message]</a></center>
                                                    </div>
                                                <%
                                                }
                                             %>
                                        </td>
                                    </tr>
                                <% } %>
                            </table>
                        </div>
                    </div>
                <% } %>
                <div style="margin-top:10px;">&nbsp;</div>
                </div>
                <div class="divright" style="height: 500px;">
                    <% Html.RenderPartial("Templates/TH_Right", Model); %>
                </div>
            </div>
        </div>
</asp:Content>
